#include <algorithm>
#include <climits>
#include <cstdio>
#include <iostream>
#include <vector>


/**
 * Luogu P1455: Purchase in Bundle
 */

struct Item {
    int root;
    int price, value;
};

std::vector<Item> items, bundles;

int find(int idx) {
    Item &item = items[idx];
    if (item.root != idx) item.root = find(item.root);
    return item.root;
}

void union_(int i1, int i2) {
    int r1 = find(i1), r2 = find(i2);
    items[r2].root = r1;
    items[r1].price += items[r2].price;
    items[r1].value += items[r2].value;
}

int main() {
    // Input
    int nItems, nPairs, money;
    scanf("%d %d %d", &nItems, &nPairs, &money);
    for (int i = 0; i < nItems; i++) {
        Item item;
        item.root = i;
        scanf("%d %d", &item.price, &item.value);
        items.push_back(item);
    }
    for (int i = 0; i < nPairs; i++) {
        int i1, i2;
        scanf("%d %d", &i1, &i2);
        i1--, i2--;
        union_(i1, i2);
    }

    // Filter out bundles
    for (int i = 0; i < nItems; i++) {
        Item &item = items[i];
        if (item.root != i) continue;
        bundles.push_back(item);
    }

    // Use DP to solve 0-1 knapsack problem
    std::vector<int> buf(money + 1, 0);
    for (auto &b : bundles) {
        for (int i = money; i >= b.price; i--)
            buf[i] = std::max(buf[i], buf[i - b.price] + b.value);
    }
    printf("%d\n", buf[money]);

    return 0;
}